$(function () {
	$("a.a-sidebar").hover(function() {
		$(this).parents("li").addClass('hover');
		$(this).click(function () {
			window.scrollTo({top:0});
		})
	}, function() {
		$(this).parents("li").removeClass("hover");
		// console.log($(this).siblings('div'))
		$(this).siblings().hover(function() {
			$(this).parents("li").addClass('hover');
		}, function() {
			$(this).parents("li").removeClass('hover');
		});
	}); 
})

function myGetStyle(obj,attr){
    if(window.getComputedStyle){
        return window.getComputedStyle(obj, null)[attr];
    }else{
        return obj.currentStyle[attr];
    }

 }

function myMultiLinear(ele,obj){
	clearInterval(ele.timer);
	ele.timer = setInterval(function(){
		var status = true;
		for (var key in obj) {
			var current = parseInt(myGetStyle(ele,key));
			var target = parseInt(obj[key]);
        	var step = current < target ? +10 : -10;  
			ele.style[key] = current + step + "px";
			if (Math.abs(current - target) > Math.abs(step)) {
				status = false;
			} 
		}
		if (status) {
			clearInterval(ele.timer);
		}
        console.log('Running-----myMultiLinear');
	},30)
}

function myMultiEaseOut(ele,obj,secmini,fn){
	secMini = secmini||30;
	// console.log(secmini,secMini)
	//1. 清除定时器
    clearInterval(ele.timer);
    //2.开启定时器
    ele.timer = setInterval(() =>{

        var bflag = true;
        for(var attr in obj){
            var current = 0;
            var target = 0;
            if(attr == "opacity"){
                current = myGetStyle(ele, attr) * 100;
                target = obj[attr] * 100;
            } else {
                current = parseInt(myGetStyle(ele, attr));
                target = parseInt(obj[attr]);
            }
            //2.1 步长=(目标-当前的位置)/10;
            var step = (target - current) / 10;
            //2.2 判断 步长
            step = step > 0 ? Math.ceil(step) : Math.floor(step);
            //2.3  新的位置=当前的位置+步长

            if(attr == "opacity"){
                ele.style.opacity = (current + step) / 100;
                ele.style.filter = `alpha(opacity=${(current + step)})`
            } else if(attr == "zIndex"){
                ele.style.zIndex = obj[attr];
            } else {
                ele.style[attr] = current + step + "px";
            }
            if(current != target){
                bflag = false;
            }
        }
        if(bflag){
            clearInterval(ele.timer);
            if(fn && typeof(fn) == "function"){// 如果 fn不等于 undefined ,就是 true
                fn.bind(ele)(ele);
            }
        }  
    },secMini)
} 